package ini

import (
	"fmt"
)

/*
*
读取带[]的ini配置时，使用开源框架（gcfg.v1）
*/
func ComplexCfg(cfgPath string) {
	//[app]
	//enabled = true
	//path = /usr/local # another comment
	//[redis]
	//db_host=127.0.0.1
	//db_port = 6379
	config := struct {
		App struct {
			Enabled bool
			Path    string
		}
		Redis struct {
			Host string
			Port float64
		}
	}{}

	err := gcfg.ReadFileInto(&config, cfgPath)

	if err != nil {
		fmt.Printf("Failed to parse config file: %s\n", err)
	}
	fmt.Println("读取[app].path:")
	fmt.Println(config.App.Path)
	fmt.Println("读取[redis].host:")
	fmt.Println(config.Redis.Host)
}
